<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/view/include/taglib.jsp"%>
<#if model??>
<html lang="cn" class="app">
<head>
    <title>后台管理 - ${model.tableDesc}</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <link rel="icon" type="image/png" href="${"$"}{contextPath}/icon.png">
    <link rel="apple-touch-icon-precomposed" href="${"$"}{contextPath}/icon.png">
    <link rel="stylesheet" href="${"$"}{ctxStatic}/js/jPlayer/jplayer.flat.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/css/animate.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/css/font.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/css/app.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/js/ztree/css/zTreeStyle.css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/js/chosen/chosen.css" type="text/css" />
    <link rel="stylesheet" href="${"$"}{ctxStatic}/js/layui/css/layui.css">
    ${"<!--[if lt IE 9]>"}
    <script src="${"$"}{ctxStatic}/js/ie/html5shiv.js"></script>
    <script src="${"$"}{ctxStatic}/js/ie/respond.min.js"></script>
    <script src="${"$"}{ctxStatic}/js/ie/excanvas.js"></script>
    ${"<![endif]-->"}
</head>

<body>
<section class="scrollable wrapper">
    <div class="row">
        <div class="col-lg-12">
            <!-- 引导开始 -->
            <ul class="breadcrumb">
                <li><a href="${"$"}{ctx}/welcome"><i class="fa fa-home"></i> 主页</a></li>
                <li></li>
                <li class="active">${model.tableDesc}管理</li>
                <li class="active">${model.tableDesc}新增</li>
            </ul>
            <!-- 引导结束 -->
        </div>
    </div>
    <form id="${model.className?uncap_first}Form" class="bs-example form-horizontal" method="post" >

        <%-- 基本信息 --%>
        <section class="panel panel-default">
            <header class="panel-heading font-bold">${model.tableDesc}新增</header>

            <div class="panel-body">
        <#list model.columns as column>
            <#if column.columnName=="id">
            <#elseif column.columnName=="createDate">
            <#elseif column.columnName=="updateDate">
            <#elseif column.columnName=="createBy">
            <#elseif column.columnName=="updateBy">
            <#elseif column.columnName=="status">
            <#--<#elseif column.columnName=="status">-->
                <#--<div class="form-group">-->
                    <#--<label class="col-lg-2 col-md-2 col-sm-2 control-label">${column.columnDesc}：</label>-->
                    <#--<div class="col-lg-4 col-md-4 col-sm-4">-->
                        <#--<select name="${column.columnName?uncap_first}" class="form-control" >-->
                            <#--<c:forEach items="${"$"}{yn}" var="m">-->
                                <#--<option value="${"$"}{m.value}" <c:if test="${"$"}{${model.className?uncap_first}.${column.columnName?uncap_first} == m.value}">selected="selected"</c:if>>${"$"}{m.label}</option>-->
                            <#--</c:forEach>-->
                        <#--</select>-->
                    <#--</div>-->
                <#--</div>-->
            <#elseif column.columnName=="remarks">
                <div class="form-group">
                    <label class="col-lg-2 col-md-2 col-sm-2 control-label">${column.columnDesc}：</label>
                    <div class="col-lg-4 col-md-4 col-sm-4">
                        <textarea id="${column.columnName?uncap_first}" class="form-control" name="${column.columnName?uncap_first}" placeholder="${column.columnDesc}" required >${"$"}{${model.className?uncap_first}.${column.columnName?uncap_first}}</textarea>
                    </div>
                </div>
            <#else>
                <div class="form-group">
                    <label class="col-lg-2 col-md-2 col-sm-2 control-label"><span class="text-danger">*</span>${column.columnDesc}：</label>
                    <div class="col-lg-4 col-md-4 col-sm-4">
                        <input id="${column.columnName?uncap_first}" type="text" class="form-control" name="${column.columnName?uncap_first}" placeholder="${column.columnDesc}" value="" required />
                    </div>
                </div>
            </#if>
        </#list>
                <div class="form-group">
                    <div class="col-lg-offset-2 col-md-offset-2 col-sm-offset-2 col-lg-10 col-md-10 col-sm-10">
                        <shiro:hasPermission name="${model.model}:${model.className?uncap_first}:create">
                        <button type="button" class="btn btn-s-md btn-info" onclick="insert${model.className?uncap_first}()">保存</button>
                        </shiro:hasPermission>
                        <button type="button" class="btn btn-s-md btn-danger" onclick="closeSelfModel()">关闭</button>
                    </div>
                </div>
            </div>
        </section>
    </form>
</section>

</body>

<script src="${"$"}{ctxStatic}/js/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="${"$"}{ctxStatic}/js/bootstrap.js"></script>
<!-- App -->
<script src="${"$"}{ctxStatic}/js/app.js"></script>
<script src="${"$"}{ctxStatic}/js/slimscroll/jquery.slimscroll.min.js"></script>
<script src="${"$"}{ctxStatic}/js/app.plugin.js"></script>
<script type="text/javascript" src="${"$"}{ctxStatic}/js/tools.js"></script>
<script type="text/javascript" src="${"$"}{ctxStatic}/js/page/paging.js"></script>
<script type="text/javascript" src="${"$"}{ctxStatic}/js/layer/layer.js"></script>
<script type="text/javascript" src="${"$"}{ctxStatic}/js/tmpl/jquery.tmpl.js"></script>
<script type="text/javascript" src="${"$"}{ctxStatic}/js/chosen/chosen.jquery.min.js"></script>
<script type="text/javascript" src="${"$"}{ctxStatic}/js/layui/layui.all.js"></script>

<script>
    ${"$"}(function(){
        //初始化带搜索下拉框，自带初始化宽度显示非100%bug
        ${"$"}(".chosen-select").chosen();
    })

    ${"/** 执行添加 @author " + model.authorNm+ " */"}
    function insert${model.className?uncap_first}(){
        if(isBlankCheck("<#list model.columns as column><#if column.columnName=="id"><#elseif column.columnName=="createDate"><#elseif column.columnName=="updateDate"><#elseif column.columnName=="createBy"><#elseif column.columnName=="updateBy"><#elseif column.columnName=="status"><#elseif column.columnName=="remarks"><#else><#if !column_has_next>${column.columnName}<#else>${column.columnName},</#if></#if></#list>","<#list model.columns as column><#if column.columnName=="id"><#elseif column.columnName=="createDate"><#elseif column.columnName=="updateDate"><#elseif column.columnName=="createBy"><#elseif column.columnName=="updateBy"><#elseif column.columnName=="status"><#elseif column.columnName=="remarks"><#else><#if !column_has_next>${column.columnDesc}<#else>${column.columnDesc},</#if></#if></#list>")){
            layer.confirm('确认提交数据吗？', {
                btn: ['确认提交','取消'] //按钮
            }, function(){
                var loadingLayer = layer.load(1, {shade: [0.1,'#fff']});//loading
                //根据项目标识获取目录
                ${"$"}.ajax({
                    type: 'post',
                    url: '${"$"}{ctx}/${model.model}/${model.className?uncap_first}/create.json?timeStamp='+new Date().getTime(),
                    dataType:"json",
                    data: $("#${model.className?uncap_first}Form").serialize(),
                    success: function (data) {
                        layer.close(loadingLayer);
                        showMsg(data.msg,function(){
                            if(data.ret==1) {//成功
                                location.href = "${"$"}{ctx}/${model.model}/${model.className?uncap_first}/update?id=" + data.data;
                            }
                        });
                    },error:function(){
                        layer.close(loadingLayer);
                        alert("程序异常");
                    }
                });
            }, function(){

            });
        }

    }

    ${"/** 关闭当前弹出框并执行 @author " + model.authorNm+ " */"}
    function closeSelfModel(){
        var index = parent.layer.getFrameIndex(window.name);
        //执行父页面的搜索功能
        parent.searchPage(1);
        parent.layer.close(index);
    }
</script>
</html>
</#if>